home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / AnyDBM_File.pm < prev    next >
Encoding:
Perl POD Document  |  1999-12-28  |  2.6 KB  |  92 lines

  1. package AnyDBM_File;
  2.  
  3. use vars qw(@ISA);
  4. @ISA = qw(NDBM_File DB_File GDBM_File SDBM_File ODBM_File) unless @ISA;
  5.  
  6. my $mod;
  7. for $mod (@ISA) {
  8.     if (eval "require $mod") {
  9.     @ISA = ($mod);    # if we leave @ISA alone, warnings abound
  10.     return 1;
  11.     }
  12. }
  13.  
  14. die "No DBM package was successfully found or installed";
  15.  
  16. =head1 NAME
  17.  
  18. AnyDBM_File - provide framework for multiple DBMs
  19.  
  20. NDBM_File, DB_File, GDBM_File, SDBM_File, ODBM_File - various DBM implementations
  21.  
  22. =head1 SYNOPSIS
  23.  
  24.     use AnyDBM_File;
  25.  
  26. =head1 DESCRIPTION
  27.  
  28. This module is a "pure virtual base class"--it has nothing of its own.
  29. It's just there to inherit from one of the various DBM packages.  It
  30. prefers ndbm for compatibility reasons with Perl 4, then Berkeley DB (See
  31. L<DB_File>), GDBM, SDBM (which is always there--it comes with Perl), and
  32. finally ODBM.   This way old programs that used to use NDBM via dbmopen()
  33. can still do so, but new ones can reorder @ISA:
  34.  
  35.     BEGIN { @AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File) }
  36.     use AnyDBM_File;
  37.  
  38. Having multiple DBM implementations makes it trivial to copy database formats:
  39.  
  40.     use POSIX; use NDBM_File; use DB_File;
  41.     tie %newhash,  'DB_File', $new_filename, O_CREAT|O_RDWR;
  42.     tie %oldhash,  'NDBM_File', $old_filename, 1, 0;
  43.     %newhash = %oldhash;
  44.  
  45. =head2 DBM Comparisons
  46.  
  47. Here's a partial table of features the different packages offer:
  48.  
  49.                          odbm    ndbm    sdbm    gdbm    bsd-db
  50.              ----     ----    ----    ----    ------
  51.  Linkage comes w/ perl   yes     yes     yes     yes     yes
  52.  Src comes w/ perl       no      no      yes     no      no
  53.  Comes w/ many unix os   yes     yes[0]  no      no      no
  54.  Builds ok on !unix      ?       ?       yes     yes     ?
  55.  Code Size               ?       ?       small   big     big
  56.  Database Size           ?       ?       small   big?    ok[1]
  57.  Speed                   ?       ?       slow    ok      fast
  58.  FTPable                 no      no      yes     yes     yes
  59.  Easy to build          N/A     N/A      yes     yes     ok[2]
  60.  Size limits             1k      4k      1k[3]   none    none
  61.  Byte-order independent  no      no      no      no      yes
  62.  Licensing restrictions  ?       ?       no      yes     no
  63.  
  64.  
  65. =over 4
  66.  
  67. =item [0] 
  68.  
  69. on mixed universe machines, may be in the bsd compat library,
  70. which is often shunned.
  71.  
  72. =item [1] 
  73.  
  74. Can be trimmed if you compile for one access method.
  75.  
  76. =item [2] 
  77.  
  78. See L<DB_File>. 
  79. Requires symbolic links.  
  80.  
  81. =item [3] 
  82.  
  83. By default, but can be redefined.
  84.  
  85. =back
  86.  
  87. =head1 SEE ALSO
  88.  
  89. dbm(3), ndbm(3), DB_File(3)
  90.  
  91. =cut
  92.